import React from 'react'
import { View, Image } from '@tarojs/components'

import './index.less'
import "taro-ui/dist/style/components/list.scss";
import Taro from '@tarojs/taro'

export default (props: any) => {
  const { businessTime, tel, address,name,latitude,longitude} = props.data
  // 拨打电话
  const telCall = () => {
    Taro.makePhoneCall({
      phoneNumber: tel //仅为示例，并非真实的电话号码
    })
  }
  // 导航
  const toNav = (e:any)=>{
    Taro.openLocation({
      latitude:114.338318,
      longitude:29.826948,
      // address:e,
      // name:e
      // address
    })
  }
  const copyTxt = (address:string)=>{
    Taro.setClipboardData({
      data: address,
      success: function (res) {
        Taro.getClipboardData({
          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  }
  return (
    <View className='concat'>
      <View className='name'>{name}</View>
      <View className='time'>营业时间：{businessTime}</View>
      <View className='tel'>
        <View className='conL'>商家电话：{tel}</View>
        <Image onClick={() => { telCall() }} className='telIco' src={IMGSRC + 'tel.png'}></Image>
      </View>
      <View className='tel'>
        <View className='conL'>商家地址：{address} </View>
        
        <Image onClick={() => { toNav(address) }} className='telIco telIco2' src={IMGSRC + 'toNav.png'}></Image>
      </View>
      <View className='copyAddresss' onClick={()=>{copyTxt(address)}}>点击此处复制商家地址</View>
    </View>
  )
}
